home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_gimp-print.idb / usr / freeware / share / aclocal / gimpprint.m4.z / gimpprint.m4
Text File  |  2002-10-07  |  9KB  |  190 lines

  1. # Configure paths for gimp-print
  2. # Roger Leigh -- Sat, 10 Feb 2001
  3. # (based on gimpprint.m4 by Owen Taylor     97-11-3)
  4.  
  5. dnl AM_PATH_GIMPPRINT([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
  6. dnl Test for GIMP-PRINT, and define GIMPPRINT_CFLAGS and GIMPPRINT_LIBS
  7. dnl
  8. AC_DEFUN(AM_PATH_GIMPPRINT,
  9. [dnl
  10. dnl Get the cflags and libraries from the gimpprint-config script
  11. dnl
  12. AC_ARG_WITH(gimpprint-prefix,[  --with-gimpprint-prefix=PFX Prefix where GIMP-PRINT is installed (optional)],
  13.             gimpprint_config_prefix="$withval", gimpprint_config_prefix="")
  14. AC_ARG_WITH(gimpprint-exec-prefix,[  --with-gimpprint-exec-prefix=PFX Exec prefix where GIMP-PRINT is installed
  15.                           (optional)],
  16.             gimpprint_config_exec_prefix="$withval", gimpprint_config_exec_prefix="")
  17. AC_ARG_ENABLE(gimpprinttest, [  --disable-gimpprinttest Do not try to compile and run a test GIMP-PRINT
  18.                           program],
  19.             , enable_gimpprinttest=yes)
  20.  
  21.   if test x$gimpprint_config_exec_prefix != x ; then
  22.      gimpprint_config_args="$gimpprint_config_args --exec-prefix=$gimpprint_config_exec_prefix"
  23.      if test x${GIMPPRINT_CONFIG+set} != xset ; then
  24.         GIMPPRINT_CONFIG=$gimpprint_config_exec_prefix/bin/gimpprint-config
  25.      fi
  26.   fi
  27.   if test x$gimpprint_config_prefix != x ; then
  28.      gimpprint_config_args="$gimpprint_config_args --prefix=$gimpprint_config_prefix"
  29.      if test x${GIMPPRINT_CONFIG+set} != xset ; then
  30.         GIMPPRINT_CONFIG=$gimpprint_config_prefix/bin/gimpprint-config
  31.      fi
  32.   fi
  33.  
  34.   AC_PATH_PROG(GIMPPRINT_CONFIG, gimpprint-config, no)
  35.   min_gimpprint_version=ifelse([$1], ,4.1.4,$1)
  36.   AC_MSG_CHECKING(for GIMP-PRINT - version >= $min_gimpprint_version)
  37.   no_gimpprint=""
  38.   if test "$GIMPPRINT_CONFIG" = "no" ; then
  39.     no_gimpprint=yes
  40.   else
  41.     GIMPPRINT_CFLAGS=`$GIMPPRINT_CONFIG $gimpprint_config_args --cflags`
  42.     GIMPPRINT_LIBS=`$GIMPPRINT_CONFIG $gimpprint_config_args --libs`
  43.     gimpprint_config_major_version=`$GIMPPRINT_CONFIG $gimpprint_config_args --version | \
  44.            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  45.     gimpprint_config_minor_version=`$GIMPPRINT_CONFIG $gimpprint_config_args --version | \
  46.            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  47.     gimpprint_config_micro_version=`$GIMPPRINT_CONFIG $gimpprint_config_args --version | \
  48.            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  49.     if test "x$enable_gimpprinttest" = "xyes" ; then
  50.       ac_save_CFLAGS="$CFLAGS"
  51.       ac_save_LIBS="$LIBS"
  52.       CFLAGS="$CFLAGS $GIMPPRINT_CFLAGS"
  53.       LIBS="$GIMPPRINT_LIBS $LIBS"
  54. dnl
  55. dnl Now check if the installed GIMP-PRINT is sufficiently new. (Also sanity
  56. dnl checks the results of gimpprint-config to some extent
  57. dnl
  58.       rm -f conf.gimpprinttest
  59.       AC_TRY_RUN([
  60. #include <gimp-print/gimp-print.h>
  61. #include <stdio.h>
  62. #include <stdlib.h>
  63.  
  64. int
  65. main ()
  66. {
  67.   int major, minor, micro;
  68.   char *tmp_version;
  69.  
  70.   system ("touch conf.gimpprinttest");
  71.  
  72.   /* HP/UX 9 (%@#!) writes to sscanf strings */
  73.   tmp_version = strdup("$min_gimpprint_version");
  74.   if (!tmp_version) {
  75.      exit(1);
  76.    }
  77.   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
  78.      printf("%s, bad version string\n", "$min_gimpprint_version");
  79.      exit(1);
  80.    }
  81.  
  82.   if ((gimpprint_major_version != $gimpprint_config_major_version) ||
  83.       (gimpprint_minor_version != $gimpprint_config_minor_version) ||
  84.       (gimpprint_micro_version != $gimpprint_config_micro_version))
  85.     {
  86.       printf("\n*** 'gimpprint-config --version' returned %d.%d.%d, but GIMP-PRINT (%d.%d.%d)\n",
  87.              $gimpprint_config_major_version, $gimpprint_config_minor_version, $gimpprint_config_micro_version,
  88.              gimpprint_major_version, gimpprint_minor_version, gimpprint_micro_version);
  89.       printf ("*** was found! If gimpprint-config was correct, then it is best\n");
  90.       printf ("*** to remove the old version of GIMP-PRINT. You may also be able to fix the\n");
  91.       printf("*** error by modifying your LD_LIBRARY_PATH enviroment variable, or by\n");
  92.       printf("*** editing /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
  93.       printf("*** required on your system.\n");
  94.       printf("*** If gimpprint-config was wrong, set the environment variable GIMPPRINT_CONFIG\n");
  95.       printf("*** to point to the correct copy of gimpprint-config, and remove the file\n");
  96.       printf("*** config.cache before re-running configure\n");
  97.     }
  98. #if defined (GIMPPRINT_MAJOR_VERSION) && defined (GIMPPRINT_MINOR_VERSION) && defined (GIMPPRINT_MICRO_VERSION)
  99.   else if ((gimpprint_major_version != GIMPPRINT_MAJOR_VERSION) ||
  100.        (gimpprint_minor_version != GIMPPRINT_MINOR_VERSION) ||
  101.            (gimpprint_micro_version != GIMPPRINT_MICRO_VERSION))
  102.     {
  103.       printf("\n*** GIMP-PRINT header files (version %d.%d.%d) do not match\n",
  104.          GIMPPRINT_MAJOR_VERSION, GIMPPRINT_MINOR_VERSION, GIMPPRINT_MICRO_VERSION);
  105.       printf("*** library (version %d.%d.%d)\n",
  106.          gimpprint_major_version, gimpprint_minor_version, gimpprint_micro_version);
  107.     }
  108. #endif /* defined (GIMPPRINT_MAJOR_VERSION) ... */
  109.   else
  110.     {
  111.       if ((gimpprint_major_version > major) ||
  112.         ((gimpprint_major_version == major) && (gimpprint_minor_version > minor)) ||
  113.         ((gimpprint_major_version == major) && (gimpprint_minor_version == minor) && (gimpprint_micro_version >= micro)))
  114.       {
  115.         return 0;
  116.        }
  117.      else
  118.       {
  119.         printf("\n*** An old version of GIMP-PRINT (%d.%d.%d) was found.\n",
  120.                gimpprint_major_version, gimpprint_minor_version, gimpprint_micro_version);
  121.         printf("*** You need a version of GIMP-PRINT newer than %d.%d.%d. The latest version of\n",
  122.            major, minor, micro);
  123.         printf("*** GIMP-PRINT is always available from\n");
  124.     printf("*** http://sourceforge.net/project/showfiles.php?group_id=1537.\n");
  125.         printf("***\n");
  126.         printf("*** If you have already installed a sufficiently new version, this error\n");
  127.         printf("*** probably means that the wrong copy of the gimpprint-config shell script is\n");
  128.         printf("*** being found. The easiest way to fix this is to remove the old version\n");
  129.         printf("*** of GIMP-PRINT, but you can also set the GIMPPRINT_CONFIG environment to\n");
  130.         printf("*** point to the correct copy of gimpprint-config. (In this case, you will have\n");
  131.         printf("*** to modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
  132.         printf("*** so that the correct libraries are found at run-time))\n");
  133.       }
  134.     }
  135.   return 1;
  136. }
  137. ],, no_gimpprint=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  138.        CFLAGS="$ac_save_CFLAGS"
  139.        LIBS="$ac_save_LIBS"
  140.      fi
  141.   fi
  142.   if test "x$no_gimpprint" = x ; then
  143.      AC_MSG_RESULT(yes)
  144.      ifelse([$2], , :, [$2])
  145.   else
  146.      AC_MSG_RESULT(no)
  147.      if test "$GIMPPRINT_CONFIG" = "no" ; then
  148.        echo "*** The gimpprint-config script installed by GIMP-PRINT could not be found"
  149.        echo "*** If GIMP-PRINT was installed in PREFIX, make sure PREFIX/bin is in"
  150.        echo "*** your path, or set the GIMPPRINT_CONFIG environment variable to the"
  151.        echo "*** full path to gimpprint-config."
  152.      else
  153.        if test -f conf.gimpprinttest ; then
  154.         :
  155.        else
  156.           echo "*** Could not run GIMP-PRINT test program, checking why..."
  157.           CFLAGS="$CFLAGS $GIMPPRINT_CFLAGS"
  158.           LIBS="$LIBS $GIMPPRINT_LIBS"
  159.           AC_TRY_LINK([
  160. #include <gimp-print/gimp-print.h>
  161. #include <stdio.h>
  162. #include <string.h>
  163. ],      [ return ((gimpprint_major_version) || (gimpprint_minor_version) || (gimpprint_micro_version)); ],
  164.         [ echo "*** The test program compiled, but did not run. This usually means"
  165.           echo "*** that the run-time linker is not finding GIMP-PRINT or finding the wrong"
  166.           echo "*** version of GIMP-PRINT. If it is not finding GIMP-PRINT, you'll need to set"
  167.           echo "*** your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  168.           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
  169.           echo "*** is required on your system"
  170.       echo "***"
  171.           echo "*** If you have an old version installed, it is best to remove it, although"
  172.           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
  173.         [ echo "*** The test program failed to compile or link. See the file config.log for the"
  174.           echo "*** exact error that occured. This usually means GIMP-PRINT was incorrectly"
  175.           echo "*** installed or that you have moved GIMP-PRINT since it was installed. In the"
  176.           echo "*** latter case, you may want to edit the gimpprint-config script:"
  177.       echo "*** $GIMPPRINT_CONFIG" ])
  178.           CFLAGS="$ac_save_CFLAGS"
  179.           LIBS="$ac_save_LIBS"
  180.        fi
  181.      fi
  182.      GIMPPRINT_CFLAGS=""
  183.      GIMPPRINT_LIBS=""
  184.      ifelse([$3], , :, [$3])
  185.   fi
  186.   AC_SUBST(GIMPPRINT_CFLAGS)
  187.   AC_SUBST(GIMPPRINT_LIBS)
  188.   rm -f conf.gimpprinttest
  189. ])
  190.